home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
menu
/
mxmenu.exe
/
NOVTRANS.MNU
< prev
next >
Wrap
Text File
|
1994-03-07
|
14KB
|
478 lines
Comment
========================================================================
Novell menu to MarxMenu Translator:
Copyright 1989-93 by Marc Perkel * All rights reserved.
Usage: MARXMENU NOVTRANS <novell menu>
This program was written to translate Novell menus to MarxMenus. It is
not an exact translation, but does the bulk of the work. It is up to you
to edit the output file and tune the menu the way you want.
I have made no attempt to copy color information. I am not presenting
selections in sorted order, but in the order in which they are defined.
If the translation is successful then your old menu will be renamed with
a NOV extension.
========================================================================
EndComment
Var
Menus
MenuPtr
LinePtr
ThisMenu
ThisChoice
CommandPtr
BoxDim
VarNum
PromptLine
Out
Cap
InputAVar
NovellFileName
MarxMenuFileName
NovellTempFileName
NovFileExists
Greek
Titles
QuietMode
NovLines
;----- Translator Messages
Const
TopMessage = "Joe Blow's Master Menu"
BottomMessage = "*-<< Acme Manufacturing Company >>-*"
;----- If you want the Greek Column effect, set to true
Greek = False
Qualifier MenuName MenuTitle YPos XPos MenuColor MenuChoices
Qualifier ChoiceName ChoiceCmd
Comment
========================================================================
This is the main body of the NovTrans Program.
========================================================================
EndComment
if not NetWorkVersion
ClearScreen
Writeln
Writeln 'This translator requires the network version of MarxMenu to Run!'
endif
PreAmble
GetFileNames
Parse
if MenuPtr = 0
Writeln
Writeln
Writeln 'Error: ' NovellTempFileName ' is not a Novell menu!
ExitMenu
endif
Header
WriteOutMenus
Footer
ClearScreenFirst Off
Writeln
if QuietMode
Execute 'MARXCOMP.EXE ' + MarxMenuFileName + ' /U'
else
Execute 'MARXCOMP.EXE ' + MarxMenuFileName
endif
if ReturnCode = 0
Writeln
Writeln 'Menu Translation Sucessful!'
Writeln
if not NovFileExists and not QuietMode
Writeln 'Renaming ' NovellTempFileName ' to ' ForceExtension(NovellTempFileName,'NOV')
FileRename(NovellTempFileName,ForceExtension(NovellTempFileName,'NOV'))
Writeln 'Renaming ' MarxMenuFileName ' to ' NovellTempFileName
FileRename(MarxMenuFileName,NovellTempFileName)
Writeln
Write 'Your original novell menu has been renamed to: '
Writeln ForceExtension(NovellTempFileName,'NOV')
Writeln
endif
Writeln 'To test your menu type MARX ' NovellFileName '.
endif
ExitMenu
Comment
=====================================
Subroutine area.
=====================================
EndComment
;----- Initilize Variables and Environment
Procedure PreAmble
ClearScreenOnExit Off
if UpperCase(ParamStr(3)) = 'U'
Quietmode = True
OutFile = 'NUL'
endif
StandardIO
Writeln
NovellFileName = UpperCase(ParamStr(2))
if Extension(NovellFileName) = 'MNU'
length(NovellFileName) = length(NovellFileName) - 4
endif
Usage
EndProc
;----- Proper Usage Procedure
Procedure Usage
if NovellFileName = ''
Writeln('Converts Novell menus to MarxMenus.')
Writeln
Writeln(' Usage: MarxMenu NovTrans <menu>')
ExitMenu
endif
EndProc
;----- Get File Names
Procedure GetFileNames
if pos('.',NovellFileName) = 0
if QuietMode
NovellTempFileName = ForceExtension(NovellFileName,'MNU')
else
NovellTempFileName = ForceExtension(NovellFileName,'NOV')
if ExistOnPath(NovellTempFileName) = ''
NovellTempFileName = ForceExtension(NovellFileName,'MNU')
else
NovFileExists = True
endif
endif
endif
NovellTempFileName = ExistOnPath(NovellTempFileName)
if NovellTempFileName = ''
Writeln 'Error: ' NovellFileName ' does not exist!'
ExitMenu
endif
if NovFileExists
MarxMenuFileName = ForceExtension(NovellTempFileName,'MNU')
else
MarxMenuFileName = ForceExtension(NovellTempFileName,'TMP')
endif
ReadTextFile(NovellTempFileName,NovLines)
Writeln 'Creating ' MarxMenuFileName
EndProc
;----- Write out the MarxMenu Source Header
Procedure Header
FileAssign(Out,MarxMenuFileName)
FileCreate(Out)
WriteOut
WriteOut 'Comment'
WriteOut '=========================================================='
WriteOut
WriteOut 'This file was converted from Novell Menu: ',NovellTempFileName
WriteOut
WriteOut 'It should behave in a similar way to the original menu but'
WriteOut 'not necessarilly exactly the same. It will be close enough'
WriteOut 'for you to fine tune it the way you want.'
WriteOut
WriteOut 'To add a choice to a menu simply use the AddChoice command'
WriteOut 'then add the appropiate Onkey statement.'
WriteOut 'The menu will make the size adjustments accordinaly.'
WriteOut
WriteOut ' Example:'
WriteOut ' AddChoice("Print Console",10)'
WriteOut ' ...'
WriteOut ' ...'
WriteOut ' OnKey Task(10)'
WriteOut ' cd \public'
WriteOut ' PConsole'
WriteOut ' ...'
WriteOut
WriteOut "If you want to change the menu's center, pass the XY"
WriteOut "coordinates to menu's CenterStretchBox procedure."
WriteOut
WriteOut ' Example:'
WriteOut ' CenterStretchBox("Menu Header",40,12)'
WriteOut
WriteOut 'This will cause the menu to center at Col 40, Row 12'
WriteOut
WriteOut 'Instead of defining the center of the box, there is a command'
WriteOut 'CornerStretchBox where the box grows down and right.'
WriteOut
WriteOut ' Example:'
WriteOut ' CornerStretchBox("Menu Header",8,6)'
WriteOut
WriteOut 'To control custom features, edit CUSTOM.INC and other INCLUDE Files.'
WriteOut
WriteOut '========================================================='
WriteOut 'EndComment'
WriteOut
WriteOut ';----- Create Variables'
WriteOut
WriteOut 'var'
WriteOut ' NovVar'
WriteOut ' KeepUsersInMenu'
WriteOut
WriteOut
WriteOut ';----- Here is where you add you own menu title and status line message'
WriteOut
WriteOut 'MenuTitle = "',TopMessage,'"'
WriteOut 'StatusLineText = "',BottomMessage,'"'
WriteOut
WriteOut ';----- Load Novell look and feel routines'
WriteOut
WriteOut 'Include "CUSTOM.INC"'
if Greek then WriteOut 'Greek = True'
WriteOut
WriteOut 'KeepUsersInMenu Off ;Change to On to keep users in menu.'
WriteOut
WriteOut 'Comment'
WriteOut '================================='
WriteOut
WriteOut 'MarxMenu is capable of software metering. This means that it can'
WriteOut 'limit the number of users of an application to a fixed amount.'
WriteOut
WriteOut ' OnKey Task (2)'
WriteOut " |if Limit('LOTUS',6) then Return ;limit Lotus to 6 Users"
WriteOut ' CD \PUBLIC\LOTUS'
WriteOut ' 123'
WriteOut
WriteOut 'Read the METER.INC file for more details.'
WriteOut
WriteOut '================================='
WriteOut 'EndComment'
WriteOut
WriteOut "Include 'METER.INC' ;Software Metering"
WriteOut
WriteOut 'Comment'
WriteOut '================================='
WriteOut
WriteOut 'In order to add menu choices conditionally you would append the'
WriteOut 'choices to the end of the array after all the default choices'
WriteOut 'are set. For Example:'
WriteOut
WriteOut ' if InGroup("ACCOUNTING","MANAGERS")'
WriteOut ' AddChoice("Payroll Menu",10)'
WriteOut ' endif'
WriteOut
WriteOut 'Here is where menus are created.'
WriteOut
WriteOut '================================='
WriteOut 'EndComment'
WriteOut
FileFlush(Out);
EndProc
;----- Write out the MarxMenu Source Footer
Procedure Footer
WriteOut
WriteOut ';----- End of Menu Translation'
FileClose(Out)
EndProc
;----- Preprocess Lines
Procedure Parse
Var ChoicePtr TotalLines X St St2
TotalLines = NumberOfElements(NovLines)
Writeln('Parsing Novell Menu source code ...')
MenuPtr = 0
loop NovLines
if (LoopIndex Mod 10 = 0) or (LoopIndex = TotalLines)
Write Cr
Write('Processing Line # ',LoopIndex,' of ',TotalLines)
endif
if left(LoopVal,1) = '%'
ChoicePtr = 0
CommandPtr = 0
MenuPtr = MenuPtr + 1
Actual ThisMenu = Loc Menus[MenuPtr]
St = mid(LoopVal,2,255)
Trim(St)
X = pos(',',St)
if X = 0 then X = succ(Length(St))
ThisMenu.MenuTitle = left(St,X - 1)
Trim(ThisMenu.MenuTitle)
AppendArray(Titles,UpperCase(ThisMenu.MenuTitle))
delete(St,1,X)
St2 = ' '
if MenuPtr < 10 then St2 = St2 + ' '
ThisMenu.MenuName = 'Menu' + Str(MenuPtr) + St2 + '{' + ThisMenu.MenuTitle + '}'
ThisMenu.YPos = value(NextWord(St))
ThisMenu.XPos = value(NextWord(St))
ThisMenu.MenuColor = value(NextWord(St))
else
if left(LoopVal,1) > ' '
CommandPtr = 0
ChoicePtr = ChoicePtr + 1
Trim(LoopVal)
if Mid(LoopVal,2,1) = '.'
Delete(LoopVal,1,2)
Trim(LoopVal)
endif
;----- Get rid of multiple spaces
while pos(' ',LoopVal) > 0
delete(LoopVal,pos(' ',LoopVal),1)
endwhile
;----- Get rid of double quotes
while pos('"',LoopVal) > 0
delete(LoopVal,pos('"',LoopVal),1)
endwhile
ThisMenu.MenuChoices[ChoicePtr].ChoiceName = LoopVal
else
if LoopVal > ''
if ChoicePtr = 0
Writeln
Writeln 'Error in menu line: ' LoopIndex
ExitMenu
endif
CommandPtr = CommandPtr + 1
ThisMenu.MenuChoices[ChoicePtr].ChoiceCmd[CommandPtr] = LoopVal
endif
endif
endif
endloop
EndProc
;----- Create the Menu Choices Array
Procedure WriteOutMenuChoices
Writeln
Write('Translating: ' + ThisMenu.MenuName + ' ... ')
WriteOut
WriteOut ';=============[ ' + ThisMenu.MenuTitle + ' ]============*'
WriteOut
if MenuPtr > 1
WriteOut ':',Left(ThisMenu.MenuName,pred(pos(' ',ThisMenu.MenuName)))
WriteOut
endif
loop ThisMenu.MenuChoices
WriteOut ' AddChoice("' + LoopVal.ChoiceName + '",' + Str(LoopIndex) + ')'
endloop
WriteOut
WriteOut 'CenterStretchBox("' + ThisMenu.MenuTitle + '",' + Str(ThisMenu.XPos) + ',' + Str(ThisMenu.YPos) + ')'
WriteOut
EndProc
;----- Create the Onkey Statements
Procedure WriteOutOnkeyChoices
var St X Y Z
loop ThisMenu.MenuChoices
Actual ThisChoice = Loc LoopVal
WriteOut 'OnKey Task(' + Str(LoopIndex) + ')'
loop ThisChoice.ChoiceCmd
Trim(LoopVal)
if UpperCase(LoopVal) = '!LOGOUT' then LoopVal = '|Logoff'
if Left(LoopVal,1) = '%'
delete(LoopVal,1,1)
Trim(LoopVal)
X = PosInList(UpperCase(LoopVal),Titles)
if X = 0
Writeln
Writeln 'Error: Menu ' LoopVal ' not Found!'
ExitMenu
endif
LoopVal = '^' + Menus[X].MenuName
endif
if (pos('@',LoopVal) > 0) and (Pos('@ECHO',UpperCase(LoopVal)) = 0)
X = 1
while X <= length(LoopVal)
while (X <= length(LoopVal)) and (mid(LoopVal,X,1) <> '@')
X = X + 1
endwhile
Z[1] = mid(LoopVal,X,1)
Z[2] = mid(LoopVal,X + 1,1)
if (Z[1] = '@') and (((Z[2] > '0') and (Z[3] <= '9')) or (Z[2] = '"'))
if Z[2] = '"'
insert(' ',LoopVal,X + 1)
VarNum = 10
else
VarNum = ord(Z[2]) - 48
endif
InputAVar = mid(LoopVal,X + 2,1) = '"'
if InputAVar
Y = X + 3
while (mid(LoopVal,Y,1) <> '"') and (Y <= length(LoopVal))
Y = Y + 1
endwhile
PromptLine = mid(LoopVal,X + 3,Y - (X + 3))
else
Y = X + 1
endif
delete(LoopVal,X,Y - X + 1)
insert('" NovVar[' + Str(VarNum) + '] "',LoopVal,X)
if InputAVar
WriteOut ' |NovVar[' Str(VarNum) '] = ReadTextLine("' + PromptLine + '","",0,21)'
WriteOut ' |if LastKey = Esc'
WriteOut ' |LastKey = " "'
WriteOut ' | Return ;Abort if ESC Pressed'
WriteOut ' |endif'
endif
endif
endwhile
LoopVal = '|Bat "' + LoopVal + '"'
if right(LoopVal,2) = '""'
length(LoopVal) = length(LoopVal) - 2
endif
Trim(LoopVal)
endif
WriteOut ' ' + LoopVal
endloop
WriteOut
endloop
EndProc
;----- Create the Menus
Procedure WriteOutMenus
Writeln
Loop Menus
MenuPtr = LoopIndex
Actual ThisMenu = Loc LoopVal
WriteOutMenuChoices
WriteOutOnkeyChoices
if MenuPtr = 1
WriteOut 'OnKey ESC'
WriteOut ' |if not KeepUsersInMenu or NovConsoleOperator'
WriteOut ' | LeaveMenu'
WriteOut ' |endif'
WriteOut
endif
EndLoop
EndProc
Procedure WriteOut ($OutSt)
FileWriteln(Out,OutSt)
EndProc